#include <stdio.h>
#include <stdlib.h>
#include <omp.h>

int main() {
    int m, i, c, count;
    scanf("%d", &m);
    char input[100];
    fgets(input, sizeof(input), stdin);
    sscanf(input, "%d", &count);

    int *arr = (int *)malloc(m * sizeof(int)); 

    for (i = 0; i < m; i++) {
        sscanf(input, "%d", &c);
        arr[i] = c;
    }

    for (i = 0; i < count; i++) {
        int start, end, score;
        sscanf(input, "%d %d %d", &start, &end, &score);
        for (int j = start - 1; j <= end - 1; j++)
            arr[j] = arr[j] + score;
    }

    int min = arr[0];

 
    for (i = 0; i < m; i++) {
        if (arr[i] < min)
            min = arr[i];
    }

    printf("%d", min);

    free(arr); 
    return 0;
}
